package org.minos.edit
{
	import com.alvasun.laf.chrome.ChromeLAF;
	import flash.display.Sprite;
	import flash.events.Event;
	import org.aswing.air.JNativeWindow;
	import org.aswing.AsWingManager;
	import org.aswing.AsWingUtils;
	import org.aswing.BorderLayout;
	import org.aswing.Container;
	import org.aswing.JFrame;
	import org.aswing.JPanel;
	import org.aswing.JWindow;
	import org.aswing.SoftBoxLayout;
	import org.aswing.UIManager;
	import org.ichow.core.BaseMain;
	import org.ichow.version.VersionInfo;
	import org.minos.edit.version.Version;
	import org.minos.edit.view.components.Menu;
	import org.minos.edit.view.components.SceneTable;
	import org.minos.edit.view.components.ToolBar;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class Main extends BaseMain
	{
		public static const NAME : String = "XMLEdit";
		
		public var menuContainer : Menu;
		public var mainWindow : JWindow;
		public var toolContainer : ToolBar;
		public var sceneContainer : SceneTable;
		
		public function Main() : void
		{
			super( NAME );
		}
		
		override protected function init( e : Event = null ) : void
		{
			super.init( e );
			VersionInfo.init( this , Version , Main.NAME );
			
			initAswing()
			EditFacate.getInstance().startup( this );
		}
		
		private function initAswing() : void
		{
			AsWingManager.initAsStandard( this );
			
			UIManager.setLookAndFeel( new ChromeLAF() );
			AsWingUtils.updateAllComponentUIInMemory();
			
			menuContainer = new Menu();
			toolContainer = new ToolBar();
			sceneContainer = new SceneTable();
			
			mainWindow = new JWindow();
			
			var pane : Container = mainWindow.getContentPane();
			pane.setLayout( new BorderLayout() );
			
			var top : JPanel = new JPanel( new SoftBoxLayout( SoftBoxLayout.Y_AXIS ) );
			top.append( menuContainer );
			top.append( toolContainer );
			pane.append( top , BorderLayout.NORTH );
			
			pane.append( sceneContainer , BorderLayout.CENTER );
			
			mainWindow.setSizeWH( stage.stageWidth , stage.stageHeight );
			mainWindow.show();
			
			initControllers();
		}
		
		private function initControllers() : void
		{
			stage.addEventListener( Event.RESIZE , onResized );
			
		}
		
		private function onResized( e : Event ) : void
		{
			mainWindow.setSizeWH( stage.stageWidth , stage.stageHeight );
		}
	
	}

}